import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;

import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

/**
 * 
 */

/**
 * @author Simon
 *
 */
public class SelectionPanel extends JPanel implements ActionListener
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -2423107288003282331L;
	//ArrayList<College> allColleges;
	JComboBox collegeBox;
	JComboBox facultyBox;
	String [] collegeList = new String []{""};
	String [] facultyList = new String []{""};
	String selectedCollege;
	boolean collegePicked;
	

	public SelectionPanel(String name, String [] colleges)
	{
		this.collegeList = colleges;
		Border etched = BorderFactory.createEtchedBorder();
		Border titled = BorderFactory.createTitledBorder(etched, name);
		this.setBorder(titled);
		this.setLayout(new FlowLayout());
		this.add(new JLabel("College:"));
		collegeBox = new JComboBox(collegeList);
		collegeBox.addActionListener(this);
		collegeBox.setActionCommand(this.getSelectedCollege());
		this.add(collegeBox);
		this.add(new JLabel("Faculty:"));
		facultyBox = new JComboBox(facultyList);
		this.add(facultyBox);
		
		this.setPreferredSize(getPreferredSize());
	}
	
	public Dimension getPreferredSize()
	{
		return new Dimension(580, 70);
	}
	public String getSelectedCollege()
	{
		return (String)this.collegeBox.getSelectedItem();
	}

	public String getSelectedFaculty()
	{
		return (String)this.facultyBox.getSelectedItem();
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e)
	{
		this.selectedCollege = (String)collegeBox.getSelectedItem();
		if(!this.selectedCollege.equals("Select College"))
		{
			this.collegePicked = true;
		}
		else
			collegePicked = false;
	}
}
